﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Net;

namespace Chaos.commands
{
    public class connect : ICommand
    {
        public event EventHandler CanExecuteChanged
        {
            add { CommandManager.RequerySuggested += value; }
            remove { CommandManager.RequerySuggested -= value; }
        } 
        
        public virtual bool CanExecute(object parameter)
        {
            network.gameclient c = System.Windows.Application.Current.FindResource("game_client") as network.gameclient;
            if (c != null)
            {
                return !c.Running;
            }
            return false;
        }

        public virtual void Execute(object parameter)
        {
            network.gameclient c = System.Windows.Application.Current.FindResource("game_client") as network.gameclient;
            if (c != null)
            {
                c.open(parameter as IPEndPoint);
            }
        }
    }
}
